#include <iostream>
#include <bitset>
#include <algorithm>
#define int long long
using namespace std;
const int maxn = 3005;
int T,n,m,L,V,p[maxn],ans,ans2; //ok[i][j]: cam i can shot j
struct Car{
    int d,v,a;
}a[maxn];
bitset<maxn>All,ReAll;
struct Bst{
    bitset<maxn> B;
    friend bool operator <(Bst A,Bst B){
        return A.B.count() > B.B.count();
    }
}ok[maxn];

inline void init(){
//TODO
    ans = ans2 = 0;
    All.reset();
    for(int i = 1;i<=n;i++){
        ok[i].B.reset();
    }
}

inline int dis_up(int idx){
    //farest place Or last place
    if(a[idx].a == 0){
        if(a[idx].v <= V){
            return -1; // no hit
        }else{
            return a[idx].d;
        }
    }
    if(a[idx].v>V && a[idx].a >0) return a[idx].d;
    if(a[idx].v <= V && a[idx].a <= 0) return -1;
    if((V*V-a[idx].v*a[idx].v) % (2*abs(a[idx].a)) == 0){
        int ret = a[idx].d + (V*V-a[idx].v*a[idx].v) / (2*a[idx].a);
        if(a[idx].a>0)ret++;
        else ret--;
        if(a[idx].a>0){
            if(ret>L)return -1;
            else return ret;
        }else{
            if(ret>L)return L;
            else return ret;
        }
    }
    int ret = a[idx].d + (int)(1.0*(long double)(V*V-a[idx].v*a[idx].v) / (long double)(2.0*a[idx].a) +1.0)-1*(a[idx].a > 0);
    if(a[idx].a > 0){
        if(ret>L)return -1;
        else return ret;
    }else{
        if(ret>L)return L;
        else return ret;
    }
}
inline int Find(int idx,int Pos){
    int Cam = 0;
    //cout << "idx:" << idx << endl;
    if(a[idx].a >= 0){
        Cam = lower_bound(p+1,p+m+1,Pos) - p;
        //cout << "Pos:" << Pos << ",Cam:" << Cam << endl;
        if(Cam == m+1) return Cam;
        for(int i = Cam;i<=m;i++){
            ok[i].B[idx]=true;
            //cout << i << "," << idx << " yes\n"; 
        }
    }else{
        Cam = lower_bound(p+1,p+m+1,Pos) - p;
        Cam--;
        //cout << "Pos:" << Pos << ",Cam:" << Cam << endl;
        if(p[Cam] < a[idx].d || Cam == 0) return Cam;
        for(int i = Cam;i>=1 && p[i]>=a[idx].d;i--){
            ok[i].B[idx]=true;
            //cout << i << "," << idx << " yes\n"; 
        }
    }
    ans++;
    return Cam;
}
inline void solve(){
    for(int i = 1;i<=n;i++){
        int Hit = dis_up(i);
        //cout << "i:" << Hit << endl;
        if(Hit==-1) continue;
        Find(i,Hit);
    }
    cout << ans << " ";
    while((int)All.count() != ans){
        sort(ok+1,ok+m+1);
        All |= ok[1].B;
        ReAll = All;
        ReAll.flip();
        for(int i = 1;i<=m;i++){
            ok[i].B &= ReAll;
        }
        ans2++;
    }  
    cout << m-ans2;
    
    cout << endl;
}

signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> T;
    while(T--){
        init();
        cin >> n >> m >> L >> V;
        for(int i = 1;i<=n;i++){
            cin >> a[i].d >> a[i].v >> a[i].a;
        }
        for(int i = 1;i<=m;i++){
            cin >> p[i];
        }
        solve();
    }
    return 0;
}

//Good luck CSP-S2 2024 
//RP++
//Wel and doowzs blesses me.
